









<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>memos2 - User's guide</title>
    <link rel="stylesheet" href="./css/maven-theme.css" type="text/css" />
    <link rel="stylesheet" href="./css/maven-base.css" type="text/css"/>
    <link rel="stylesheet" href="./css/prettify.css" type="text/css"/>
    <link rel="stylesheet" href="./css/print.css" type="text/css" media="print" />
    <script type="text/javascript" src="./js/prettify.js"></script>
    <script type="text/javascript" src="./js/niftycube.js"></script>
    <script type="text/javascript">
        window.onload=function() {
            Nifty("div\#wrapper", "big");
            Nifty("div#breadcrumbs", "small");
            Nifty("div\#navcolumn", "small");
            Nifty("div.source", "medium");
            prettyPrint();
        }
    </script>
          <meta name="author" content="Simone Tripodi" />
          </head>
  <body>
    <div id="wrapper">
        <div id="banner">
                        <div id="bannerLeft">
    
                                            <img src="images/logo.png" alt="memos2" />
    
            </div>
                            <div class="clear">
            <hr/>
          </div>
        </div>
        <div id="breadcrumbs">
              
  

  
    
            
  
    
            <div class="xleft">
        <span id="publishDate">Last Published: 2010-01-17</span>
                  &nbsp;| <span id="projectVersion">Version: 2.0</span>
                      </div>
                <div class="xright">      
  

  
    
            
  
    
  </div>
          <div class="clear">
            <hr/>
          </div>
        </div>
        <div id="leftColumn">
          <div id="navcolumn">
               
  

  
    
            
  
    
                       <h5>memOS2</h5>
            <ul>
              
    <li class="none">
                    <a href="index.html">Introduction</a>
          </li>
              
    <li class="none">
              <strong>User's Guide</strong>
        </li>
              
    <li class="none">
                    <a href="faq.html">FAQ</a>
          </li>
          </ul>
              <h5>Miscellaneous</h5>
            <ul>
              
    <li class="none">
                    <a href="stats.html">Project stats</a>
          </li>
              
    <li class="none">
                    <a href="memos2-2.0.pdf">PDF Manual</a>
          </li>
          </ul>
              <h5>Project Documentation</h5>
            <ul>
              
                
                    
                  
                  
                  
                  
                  
                  
                  
                  
                  
              
        <li class="collapsed">
                    <a href="project-info.html">Project Information</a>
                </li>
              
                
                    
                  
                  
                  
                  
                  
                  
                  
                  
              
        <li class="collapsed">
                    <a href="project-reports.html">Project Reports</a>
                </li>
          </ul>
              <h5>External Links</h5>
            <ul>
              
    <li class="none">
                    <a href="">Project Page</a>
          </li>
              
    <li class="none">
                    <a href="downloads/list">Downloads</a>
          </li>
              
    <li class="none">
                    <a href="http://fabrizio.zellini.org/oscache-memcached-memos" class="externalLink">memOS</a>
          </li>
              
    <li class="none">
                    <a href="http://www.opensymphony.com/oscache/" class="externalLink">OSCache</a>
          </li>
              
    <li class="none">
                    <a href="http://www.danga.com/memcached/" class="externalLink">Memcached</a>
          </li>
              
    <li class="none">
                    <a href="../spymemcached/">Spy Memcached</a>
          </li>
          </ul>
                                               <a href="http://maven.apache.org/" title="Built by Maven" class="poweredBy">
            <img class="poweredBy"
                 alt="Built by Maven"
                 src="./images/logos/maven-feather.png"
                 width="90"
                 height="30"
                 border="1" />
          </a>
                           
  

  
    
            
  
    
            </div>
        </div>
        <div id="bodyColumn">
          <div id="contentBox">
            <div class="section"><h2>Before coding</h2>
<p>Ready to start? First of all, configure in your <tt>pom.xml</tt> the <tt>repository</tt>:</p>
<div class="source"><pre>&lt;repositories&gt;
  ...
  &lt;repository&gt;
      &lt;id&gt;memos2-repository&lt;/id&gt;
      &lt;name&gt;memos2 Repository for Maven&lt;/name&gt;
      &lt;url&gt;http://memos2.googlecode.com/svn/repo&lt;/url&gt;
      &lt;layout&gt;default&lt;/layout&gt;
  &lt;/repository&gt;
  ...
&lt;/repositories&gt;</pre>
</div>
<p>then, add the following dependency:</p>
<div class="source"><pre>&lt;dependencies&gt;
    ...
    &lt;dependency&gt;
        &lt;groupId&gt;com.google.code&lt;/groupId&gt;
        &lt;artifactId&gt;memos2&lt;/artifactId&gt;
        &lt;version&gt;XX.XX&lt;/version&gt;
        &lt;scope&gt;runtime&lt;/scope&gt;
    &lt;/dependency&gt;
    ...
&lt;/dependencies&gt;</pre>
</div>
<p>Users can set the <tt>runtime</tt> scope for <i>memos2</i> since they don't have code to integrate into their own.</p>
</div>
<div class="section"><h2>Using the Persistence Listener</h2>
<p>To enable it, just set the <tt>cache.persistence.class</tt> property in the classpath resource <tt>oscache.properties</tt> as:</p>
<div class="source"><pre>cache.persistence.class=com.google.code.memos2.MemcachedListener</pre>
</div>
<p>Follow below supported properties users can add to <tt>oscache.properties</tt> classpath resource to configure the listener:</p>
<table class="bodyTable"><tbody><tr class="a"><th align="center">property</th>
<th align="center">description</th>
<th align="center">default</th>
</tr>
<tr class="b"><td align="center">cache.memos2.servers</td>
<td align="center">spaces separated <tt>${server}:${port}</tt> connection string list</td>
<td align="center">localhost:11211</td>
</tr>
<tr class="a"><td align="center">cache.memos2.connectionfactory</td>
<td align="center">The <tt>net.spy.memcached.ConnectionFactory</tt> class</td>
<td align="center">net.spy.memcached.DefaultConnectionFactory</td>
</tr>
<tr class="b"><td align="center">cache.memos2.keyprefix</td>
<td align="center">The key prefix, useful when memcached servers are<br />
shared between more than one client, to avoid keys<br />
collision.</td>
<td align="center">_oscache_</td>
</tr>
<tr class="a"><td align="center">cache.memos2.expiration</td>
<td align="center">The number of seconds entries will be stored</td>
<td align="center">the number of seconds in 30 days</td>
</tr>
<tr class="b"><td align="center">cache.memos2.asyncget</td>
<td align="center">Flag to enable the client to use the async get</td>
<td align="center">false</td>
</tr>
<tr class="a"><td align="center">cache.memos2.timeout</td>
<td align="center">Connection timeout for async operations (if set)</td>
<td align="center">5</td>
</tr>
<tr class="b"><td align="center">cache.memos2.timeoutunit</td>
<td align="center">The connection timeout unit for async operations</td>
<td align="center"><tt>seconds</tt>, admitted values are:<br />
* <tt>microseconds</tt>;<br />
* <tt>milliseconds</tt>;<br />
* <tt>nanoseconds</tt>;<br />
* <tt>seconds</tt>.</td>
</tr>
<tr class="a"><td align="center">cache.memos2.compression</td>
<td align="center">if true, objects will be GZIP compressed before putting them to Memcached</td>
<td align="center">false</td>
</tr>
<tr class="b"><td align="center">cache.memos2.encryptkeys</td>
<td align="center">if enabled, keys will be encrypted (Memcached keys have max size of 255 chars)</td>
<td align="center">false</td>
</tr>
</tbody>
</table>
<p>That's all, the magic happens just invoking <tt>OSCache</tt> in your code!!!</p>
</div>
<div class="section"><h2>Warning</h2>
<p>It is strongly reccomended turning off the oscache memory when using <tt>Memcached</tt>.</p>
<p>I suppose you choosed <tt>memcached</tt> because you need an high-scalable system, so to avoid getting your applications out of synch, in the <tt>oscache.properties</tt> just set:</p>
<div class="source"><pre>cache.memory=false</pre>
</div>
</div>

          </div>
        </div>
        <div class="clear">
          <hr/>
        </div>
        <div id="footer">
          <div class="xright">Copyright &#169;         
   
          2010.
    
      All Rights Reserved.    
  

  
    
            
  
    
  </div>
          <div class="clear">
            <hr/>
          </div>
        </div>
    </div>
  </body>
</html>
